package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.LogBean;
import com.project.service.ILogService;
import com.project.util.InfoResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

/**
 * @author lyl
 * description:
 */
@RestController
@RequestMapping("log")
@Api(tags = "日志相关controller")
public class LogController {
    @Autowired
    private ILogService iLogService;

    @GetMapping("showLogByPage/{pageNum}/{startDate}/{endDate}")
    private PageInfo<LogBean> showLogByPage(@PathVariable int pageNum,
                                            @PathVariable String startDate,
                                            @PathVariable String endDate) {
        return iLogService.showLogByPage(pageNum, LocalDate.parse(startDate), LocalDate.parse(endDate));
    }


    @PostMapping("addLog/{username}")
    private InfoResult addLog(@PathVariable String username) {
        return iLogService.addLog(username);
    }
}
